<input type=hidden name="fieldMap['${field.name}'].id"  <#if businessInstanceField?? && businessInstanceField.id??>value="${businessInstanceField.id}"</#if>>
<input type=hidden name="fieldMap['${field.name}'].field.id"  value="${formField.field.id}">


<tr class="listviewTR">
	<th class="listviewTD" align="center">单位</th>
	<th class="listviewContent" align="center">可研投资</th>
	<th class="listviewContent" colspan="4">&nbsp;</th>
</tr>
<#if parentFeaBatch?? && parentFeaBatch.batchLevel != "2">
	<tr class="listviewTR">
		<th class="listviewTD" align="center">
			${parentFeaBatch.company.name}
		</th>
		<th class="listviewContent" align="center">
		<#if parentFeaBatch.invest??>${parentFeaBatch.invest?c}</#if>
		万元
		</th>
		<td class="listviewContent" colspan="4">&nbsp;</td>
	</tr>
</#if>
<#if formField.readonly?? && formField.readonly=="1">
	<input type=hidden id=${field.name} name="fieldMap['${field.name}'].value" <#if businessInstanceField??>value="${businessInstanceField.value?default('')}"</#if>></input>
	
	<#if childFeaBatch_list?? && childFeaBatch_list?size gt 0>
	<#assign index=0>
		<#list childFeaBatch_list as child>
			<tr class="listviewTR">
				<td class="listviewTD" align="center">
					<input type="hidden" class="text" style="width:133px;" name="fieldMap['${field.name}'].preFeaBatchList[${index}].id" value="<#if child.id??>${child.id?default('')}</#if>" >
					<input type="hidden" class="text" style="width:133px;" name="fieldMap['${field.name}'].preFeaBatchList[${index}].company.id" value="${child.company.id?default('')}" >
					${child.company.name}
				</td>
				<td class="listviewContent" align="center">
					<input type="hidden" class="text" style="width:133px;" name="fieldMap['${field.name}'].preFeaBatchList[${index}].invest" value="<#if child.invest??>${child.invest?c}</#if>" >
					<#if child.invest??>${child.invest?c}</#if>
					万元
				</td>
				<td class="listviewContent" colspan="4">&nbsp;</td>
			</tr>
			<#assign index=index+1>
		</#list>
		<#if parentFeaBatch?? && parentFeaBatch.batchLevel == "2">
				<tr class="listviewTR">
					<td class="listviewTD" align="center">合计</td>
					<td class="listviewContent" align="center">
						<label id = "prefeabatchcount"><#if parentFeaBatch?? && parentFeaBatch.invest??>${parentFeaBatch.invest?c}<#else>0</#if></label>
					</td>
					<td class="listviewContent" colspan="4">&nbsp;</td>
				</tr>
			</#if>
	</#if>
<#else>
	
	<#if childFeaBatch_list?? && childFeaBatch_list?size gt 0>
	<#assign index=0>
		<#list childFeaBatch_list as child>
			<tr class="listviewTR">
				<td class="listviewTD" align="center">
					<input type="hidden" class="text" style="width:133px;" name="fieldMap['${field.name}'].preFeaBatchList[${index}].id" value="<#if child.id??>${child.id?default('')}</#if>" >
					<input type="hidden" class="text" style="width:133px;" name="fieldMap['${field.name}'].preFeaBatchList[${index}].company.id" value="${child.company.id?default('')}" >
					${child.company.name}
				</td>
				<td class="listviewContent" align="center">
					<input id="preFeaBatch_${index}" class="text" style="width:133px;" old="<#if child.invest??>${child.invest?c}</#if>" name="fieldMap['${field.name}'].preFeaBatchList[${index}].invest" value="<#if child.invest??>${child.invest?c}</#if>"  datarule="number" datarulejson='{"displayName":"可研投资","dataType":"number","isRequired":"0","precision":"6","length":"8"}' >
					万元
				</td>
				<td class="listviewContent" colspan="4">&nbsp;</td>
				
			</tr>
			<#assign index=index+1>
		</#list>
		<#if !parentFeaBatch?? || parentFeaBatch.batchLevel == "2">
				<tr class="listviewTR">
					<td class="listviewTD" align="center">合计</td>
					<td class="listviewContent" align="center">
						<label id = "prefeabatchcount"><#if parentFeaBatch?? && parentFeaBatch.invest??>${parentFeaBatch.invest?c}<#else>0</#if></label>
					</td>
					<td class="listviewContent" colspan="4">&nbsp;</td>
				</tr>
				
				<#assign index=0>
				<#list childFeaBatch_list as child>
						<script>
							$("#preFeaBatch_${index}").blur(function (){
						        var b = $("#preFeaBatch_${index}").val();
						        var sum = $("#prefeabatchcount").text();
						        var old = $("#preFeaBatch_${index}").attr("old");
						        
								if(!isNaN(b)){
									sum = floatAdd(sum,b);
									sum = floatSub(sum,old);
									$("#preFeaBatch_${index}").attr("old",b);
									$('#prefeabatchcount').text(sum);
								}
						     });
						</script>
					<#assign index=index+1>
				</#list>
		</#if>
	</#if>
</#if>

<script>
function floatAdd(arg1,arg2)
    {
        var r1,r2,m;
        try
        {
            r1=arg1.toString().split(".")[1].length;
        }
        catch(e)
        {
            r1=0;
        }
        try
        {
            r2=arg2.toString().split(".")[1].length;
        }
        catch(e)
        {
            r2=0;
        }
        if(isNaN(arg1) || arg1 ==""){
    		r1 = 0;
    	}
    	if(isNaN(arg2) || arg2 ==""){
    		r2 = 0;
    	}
        m=Math.pow(10,Math.max(r1,r2));
        return (arg1*m+arg2*m)/m;
    }
    
    function floatSub(arg1,arg2)
    {
        var r1,r2,m;
        try
        {
            r1=arg1.toString().split(".")[1].length;
        }
        catch(e)
        {
            r1=0;
        }
        try
        {
            r2=arg2.toString().split(".")[1].length;
        }
        catch(e)
        {
            r2=0;
        }
        if(isNaN(arg1) || arg1 ==""){
    		r1 = 0;
    	}
    	
    	if(isNaN(arg2) || arg2 ==""){
    		r2 = 0;
    	}
        m=Math.pow(10,Math.max(r1,r2));
        return (arg1*m-arg2*m)/m;
    }
</script>